package com.pesilo.mvc.model
{
	import com.pesilo.mvc.controller.ApplicationFacade;
	import com.pesilo.mvc.model.vo.BackgroundImageVO;
	import com.pesilo.mvc.model.vo.DataParamVO;
	import com.pesilo.net.http.HttpService;
	import com.pesilo.norms.Api;
	
	import flash.net.URLRequestMethod;
	
	import org.puremvc.as3.multicore.interfaces.IProxy;
	import org.puremvc.as3.multicore.patterns.proxy.Proxy;

	public class BackgroundProxy extends Proxy implements IProxy
	{
		public static const NAME:String="BackgroundProxy";
		
		public var bgVO:BackgroundImageVO;
		
		public function BackgroundProxy()
		{
			super(NAME);
		}
		
		public function getBackgroundData():void{
			var pvo:DataParamVO=new DataParamVO(Api.API_BACKGROUND_URL,getBackgroundCallBack);
			pvo.method=URLRequestMethod.GET;
			HttpService.getInstance().getData(null,pvo,true);
		}
		
		private function getBackgroundCallBack(obj:Object):void{
			trace("background data is call back!");
			bgVO=new BackgroundImageVO(obj);
			
			//show background
			ApplicationFacade.getInstance(ApplicationFacade.NAME).sendNotification(ApplicationFacade.SHOW_BACKGROUND_EVENT,bgVO);
		}
	}
}